/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.colecoes;

import java.util.ArrayList;
import java.util.Vector;
import server.entidades.Channel;
import server.entidades.User;

/**
 *
 * @author root
 */
public class ColecaoCanal {

    private Vector<Channel> canais = new Vector<Channel>();

    public synchronized void adicionarCanal(Channel Canal) {
        this.canais.add(Canal);
    }

    public synchronized void removerCanal(Channel Canal) {
        canais.remove(Canal);
    }

    public synchronized Channel getCanalPorNome(String nome) {
        for (Channel u : canais) {
            if (u.getNome().equals(nome)) {
                return u;
            }
        }
        return null;
    }

    public synchronized void stopAll(){
        canais.clear();
    }

    public Vector<Channel> getCanais() {
        return this.canais;
    }

    public void rmUserFromAll(User u){
        for(Channel c : canais){
            c.rmUser(u);
        }
    }
}
